"use strict";



//引入第三方包 开始
import Vue from 'vue';

// Vue.config.silent = true;//取消所有vue警告和日志

//引入路由对像
import VueRouter from 'vue-router';
//安装路由插件
Vue.use(VueRouter);


//引入mint-ui
//import Mint from 'mint-ui';
//import 'mint-ui/lib/style.css';
//安装插件
//Vue.use(Mint);


// mint-ui 按需引入 开始
import Header from 'mint-ui/lib/header';
import Switch from 'mint-ui/lib/switch';
import Swipe from 'mint-ui/lib/swipe';
import SwipeItem from 'mint-ui/lib/swipe-item';
import Lazyload from 'mint-ui/lib/lazyload';
import Loadmore from 'mint-ui/lib/loadmore';
import Indicator from 'mint-ui/lib/indicator';
import Button from 'mint-ui/lib/button';
Vue.component(Header.name, Header);
Vue.component(Switch.name, Switch);
Vue.component(Swipe.name, Swipe);
Vue.component(SwipeItem.name, SwipeItem);
Vue.component(Loadmore.name, Loadmore);
Vue.component(Button.name, Button);
Vue.use(Lazyload);
// mint-ui 按需引入 结束









//引入mui的样式
import './static/vendor/mui/dist/css/mui.css';
//引入全局样式
import './static/css/global.css';



//引入Axios
import Axios from 'axios';
//挂载原型
Vue.prototype.$ajax = Axios;
//默认配置
// Axios.defaults.baseURL = 'http:/loacalhost:9999/src/';
//拦截器操作loading
Axios.interceptors.request.use(config=>{

    Indicator.open({
        text: '加载中...',
        spinnerType: 'fading-circle'
      });
    return config;
});
Axios.interceptors.response.use(config=>{
   
    //获取到config中的data,进行加工
    Indicator.close();
    return config;
});



//引入momentjs
import Moment from 'moment';
import vuePriview from 'vue-preview';
Vue.use(vuePriview);


//引入第三方包 结束

//引入全局组建需要的组件对象 开始
import NavBar from './components/common/navbar.vue';
import Comment from './components/common/commnet.vue';
import MySwipe from './components/common/mySwipe.vue';


//引入全局组建需要的组件对象 结束



//定义成全局组件或者过滤器 开始
Vue.filter('converDate',function(value){
    // return Moment(value).format('YYYY-MM-DD hh:mm:ss');
    return Moment(value).format('YYYY-MM-DD'); //过滤器取决于返回的值
})
Vue.component('navBar',NavBar); //使用最好以nav-bar来使用
Vue.component('comment',Comment); 
Vue.component('mySwipe',MySwipe);//使用要以my-swipe 封装轮播图组件


//定义成全局组件或者过滤器 结束





//引入自己的vue文件 开始
import App from './app.vue';
//按需加载
// const Foo = resolve => require(['./Foo.vue'], resolve)
const Home = r => require(['./components/home/home.vue'],r);
const Member = r => require(['./components/member/member.vue'],r);
const Shopcart = r => require(['./components/shopcart/shopcart.vue'],r);
const Search = r => require(['./components/search/search.vue'],r);
const NewsList = r => require(['./components/news/newsList.vue'],r);
const NewsDetail = r => require(['./components/news/newsDetail.vue'],r);
const PhotoShare = r => require(['./components/photo/photoShare.vue'],r);
const PhotoDetail = r => require(['./components/photo/photoDetail.vue'],r);
const GoodsList = r => require(['./components/goods/goodsList.vue'],r);
const GoodsDetail = r => require(['./components/goods/goodsDetail.vue'],r);
const GoodsComment = r => require(['./components/goods/goodsComment.vue'],r);





// import Home from './components/home/home.vue';
// import Member from './components/member/member.vue';
// import Shopcart from './components/shopcart/shopcart.vue';
// import Search from './components/search/search.vue';

// import NewsList from './components/news/newsList.vue';
// import NewsDetail from './components/news/newsDetail.vue';

// import PhotoShare from './components/photo/photoShare.vue';
// import PhotoDetail from './components/photo/photoDetail.vue'

// import GoodsList from './components/goods/goodsList.vue';
// import GoodsDetail from './components/goods/goodsDetail.vue';
// import GoodsComment from './components/goods/goodsComment.vue';


//创建路由对像,并配置路由规则
let router = new VueRouter({
    linkActiveClass:"mui-active", //当前路由页面添加类名
    routes:[
        //VueRouter:路由规则配置
        {path:'/',redirect:{name:'home'}}, //重定向
        {name:'home',path:'/home',component:Home},//首页
        {name:'member',path:'/member',component:Member},//会员
        {name:'shopcart',path:'/shopcart',component:Shopcart},//购物车
        {name:'search',path:'/search',component:Search},//搜索
        {name:'news.list',path:'/news/newsList',component:NewsList}, //新闻列表
        {name:'news.detail',path:'/news/detail',component:NewsDetail}, //新闻详情
        {name:'photo.share',path:'/photo/share',component:PhotoShare}, //图片分享
        {name:'photo.detail',path:'/photo/detail/:id',component:PhotoDetail}, //图片分享详情
        {name:'goods.list',path:'/goods/list',component:GoodsList}, //商品列表
        {name:'goods.detail',path:'/goods/detail',component:GoodsDetail}, //商品详情
        {name:'goods.comment',path:'/goods/comment',component:GoodsComment}, //商品评论详情
        {name:'goods.pictureInfo',path:'/goods/pictureInfo',component:NewsDetail} //复用新闻详情组件
    

    ]

});


//引入自己的vue文件 结束

new Vue({
    el:'#app',
    router, 
    render:c => c(App)
})